/*    */ package com.zimbra.cs.account.ldap.upgrade;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.account.Config;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.Server;
/*    */ import com.zimbra.cs.account.ldap.LdapProv;
/*    */ import com.zimbra.cs.ldap.LdapClient;
/*    */ import com.zimbra.cs.ldap.LdapServerType;
/*    */ import com.zimbra.cs.ldap.LdapUsage;
/*    */ import com.zimbra.cs.ldap.ZLdapContext;
/*    */ import java.util.HashMap;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class BUG_46297
/*    */   extends UpgradeOp
/*    */ {
/*    */   void doUpgrade()
/*    */     throws ServiceException
/*    */   {
/* 38 */     ZLdapContext zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UPGRADE);
/*    */     try {
/* 40 */       doGlobalConfig(zlc);
/* 41 */       doAllServers(zlc);
/*    */     } finally {
/* 43 */       LdapClient.closeContext(zlc);
/*    */     }
/*    */   }
/*    */   
/*    */   private void doEntry(ZLdapContext zlc, Entry entry, String entryName) throws ServiceException
/*    */   {
/* 49 */     String attrName = "zimbraContactHiddenAttributes";
/*    */     
/* 51 */     this.printer.println();
/* 52 */     this.printer.println("Checking " + entryName);
/*    */     
/* 54 */     String oldValue = "dn,zimbraAccountCalendarUserType,zimbraCalResType,zimbraCalResLocationDisplayName,zimbraCalResCapacity,zimbraCalResContactEmail";
/* 55 */     String newValue = "dn,zimbraAccountCalendarUserType,zimbraCalResType,zimbraCalResLocationDisplayName,zimbraCalResCapacity,zimbraCalResContactEmail,vcardUID,vcardURL,vcardXProps";
/*    */     
/* 57 */     String curValue = entry.getAttr(attrName);
/*    */     
/* 59 */     boolean needsUpdate = (curValue == null) || ((oldValue.equals(curValue)) && (!newValue.equals(curValue)));
/*    */     
/* 61 */     if (needsUpdate) {
/* 62 */       this.printer.println("    Modifying " + attrName + " on " + entryName + " from [" + curValue + "] to [" + newValue + "]");
/*    */       
/*    */ 
/* 65 */       Map<String, Object> attr = new HashMap();
/* 66 */       attr.put(attrName, newValue);
/* 67 */       this.prov.modifyAttrs(entry, attr);
/*    */     } else {
/* 69 */       this.printer.println("    " + attrName + " already has an effective value: [" + curValue + "] on entry " + entryName + " - skipping");
/*    */     }
/*    */   }
/*    */   
/*    */   private void doGlobalConfig(ZLdapContext zlc) throws ServiceException {
/* 74 */     Config config = this.prov.getConfig();
/* 75 */     doEntry(zlc, config, "global config");
/*    */   }
/*    */   
/*    */   private void doAllServers(ZLdapContext zlc) throws ServiceException {
/* 79 */     List<Server> servers = this.prov.getAllServers();
/*    */     
/* 81 */     for (Server server : servers) {
/* 82 */       doEntry(zlc, server, "server " + server.getName());
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/upgrade/BUG_46297.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */